package com.example.lanqiu1.websocket;

import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

public class JWebSocketClient extends WebSocketClient {

    private static final String TAG = "JWebSocketClient";


    public JWebSocketClient(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        Log.d(TAG, "onOpen: webSocket连接成功");
    }

    @Override
    public void onMessage(String message) {
        Log.d(TAG, "onMessage: 收到消息"+message);
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        Log.d(TAG, "onClose: 连接关闭");
    }

    @Override
    public void onError(Exception ex) {
        Log.e(TAG, "onError: webSocket错误");
        ex.printStackTrace();
    }
}
